package cn.sofwin.blog.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import cn.sofwin.blog.entity.Article;
import cn.sofwin.blog.service.ArticleService;
import cn.sofwin.blog.service.impl.ArticleServiceImpl;

/**
 * 控制器
 * @author LetCode
 * @since 1.0
 *
 */
@WebServlet("/blog/article")
public class ArticleServlet extends HttpServlet {

    private ArticleService articleService = ArticleServiceImpl.getInstance();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id=Integer.parseInt(req.getParameter("id"));
        Article article=articleService.getArticleById(id);
        req.setAttribute("a",article);
        req.getRequestDispatcher("/show.jsp").forward(req,resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }


}